#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS 1
#endif

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
/*
http://ybt.ssoier.cn:8088/problem_show.php?pid=1234
*/
vector<int>a(10001,0);

void ac() {
	int n;
	cin >> n;
	int l = 0x3f3f3f3f, r = 0;
	for (int i = 1; i <= n; i++) {
		int x, y;
		cin >> x >> y;
		l = min(min(l, x),y);
		r = max(max(r, y),x);
		for (int j = x; j <= y; j++)
			a[j] = 1;
	}
	for (int i = l; i <= r; i++)
		if (a[i])
			continue;
		else {
			cout << "no";
			return;
		}
	cout << l << ' ' << r;
}

int main() {
	ac();
	return 0;
}